<template>
	<view class="aboutus">
		<wxparser :rich-text="aboutus" />
	</view>
</template>

<script>
	export default {
		data() {
			return {
				aboutus: '',
				timer:''
			}
		},
		onLoad() {
			if (uni.getStorageSync('user')) {
				let user = uni.getStorageSync('user')
				this.timer = setInterval(()=>{
					this.$post('user/aboutus', {
						mid: user.id
					}).then(res => {
						// console.log(res)
						if (res.code == 0) {
							this.aboutus = res.data.aboutus
						}
						if (res.code == -3) {
							clearInterval(this.timer)
							uni.showToast({
								title: '用户不存在请重新登录',
								icon: 'none',
								mask: true
							})
							uni.clearStorage()
							setTimeout(() => {
								uni.switchTab({
									url: '../index/index'
								})
							}, 1200)
						}
						if (res.code == -4) {
							clearInterval(this.timer)
							uni.showToast({
								title: '用户已被禁用',
								icon: 'none',
								mask: true
							})
							// uni.clearStorage()
							setTimeout(() => {
								uni.switchTab({
									url: '../index/index'
								})
							}, 1200)
						}
					})
				},1000)
				
			}else{
				uni.showToast({
					title:'暂未登陆',
					icon:'none'
				})
				uni.navigateBack({
					delta:1
				})
			}

		},
		onShareAppMessage(e) {
			return {
				title: '',
				path: '/pages/index/index'
			}
		},
		onUnload() {
			clearInterval(this.timer)
		},
		methods: {

		}
	}
</script>

<style lang="less">
	.aboutus {
		width: 100vw;
		padding: 20rpx;
		padding-left: 30rpx;
		padding-right: 30rpx;
		box-sizing: border-box;
	}

	.img {
		width: 100% !important;
	}
</style>
